package com.xm.rsi.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xm.rsi.model.entity.User;
import com.xm.rsi.model.vo.LoginUserVO;
import com.xm.rsi.model.vo.UserVO;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* @author xmm
* @description 针对表【user】的数据库操作Service
* @createDate 2023-09-29 18:59:39
*/
public interface UserService extends IService<User> {
    
    /**
     * 用户注册
     *
     * @param userEmail   用户账户
     * @param userPassword  用户密码
     * @param checkPassword 校验密码
     * @return 新用户 id
     */
    long userRegister(String userEmail, String userPassword, String checkPassword, String userName, String emailCode);

    /**
     * 用户登录
     *
     * @param userEmail  用户邮箱
     * @param userPassword 用户密码
     * @param request
     * @return 脱敏后的用户信息
     */
    LoginUserVO userLogin(String userEmail, String userPassword, boolean isRemember, HttpServletRequest request, HttpServletResponse response);

    /**
     * 用户注销
     *
     * @param request
     * @return
     */
    boolean userLogout(HttpServletRequest request, HttpServletResponse response);

    /**
     * 获取当前登录用户
     *
     * @param request
     * @return
     */
    User getLoginUser(HttpServletRequest request);

    /**
     * 获取脱敏的已登录用户信息
     *
     * @return
     */
    LoginUserVO getLoginUserVO(User user);

    /**
     * 获取脱敏的用户信息
     *
     * @param user
     * @return
     */
    UserVO getUserVO(User user);

    boolean isAdmin(User user);

    boolean isRootAdmin(User user);
    
    Page<UserVO> getUserVOPage(long current, long pageSize, QueryWrapper<User> queryWrapper);

    String changePwd(String userEmail, String userPassword, String checkPassword, String emailCode);

    Long addOne(String userEmail, String userPassword, String checkPassword, String userName);

    Boolean userUpdate(String userEmail, String userPassword, String checkPassword, String userName, Integer userState, String userRole);
}
